/**
 * 
 */
package com.antilia.infomaresme.provider;

import org.apache.wicket.model.LoadableDetachableModel;

import com.antilia.infomaresme.InfomaresmeApplication;
import com.antilia.infomaresme.data.dao.interfaces.IUsersDao;
import com.antilia.infomaresme.data.dataobjects.User;

/**
 * @author Ernesto
 *
 */
public class UserLdm extends LoadableDetachableModel<User> {

	private static final long serialVersionUID = 1L;
	
	private String id;
	
	public UserLdm(String user) {
		super();
		this.id = user;
	}
	
	/**
	 * @param object
	 */
	public UserLdm(User object) {
		super(object);
		this.id = object.getLogin();
	}

	/* (non-Javadoc)
	 * @see org.apache.wicket.model.LoadableDetachableModel#load()
	 */
	@Override
	protected User load() {
		return getUsersDao().loadById(id);
	}

	protected IUsersDao getUsersDao() {
		return InfomaresmeApplication.getQAApplication().getUsersDao();
	}
}
